package chai.ningning.files;

import java.io.File;
import java.io.IOException;
import java.util.Date;

public class FileTest4 {

    public static void main(String[] args)  {

        String pathname = "D:/IdeaProjects/java-advanced/files-and-streams-1/src/chai/ningning/files/FileTest4.java";

        File fod = new File( pathname );

        if (fod.exists()) {
            if (fod.isDirectory()){
                String name = fod.getName();
                System.out.println( name );

                File[] fods = fod.listFiles();
                System.out.println("子项目数" + (fods!=null ? fods.length : 0));
            }
            if(fod.isFile()){
                long size = fod.length();
                System.out.println( "size :" + size + "bytes." );
                long last = fod.lastModified(); //获得文件最后修改时间
                Date date = new Date(last) ;
                System.out.println("直接输出文件最后修改时间" + last);
                System.out.println("date 日期格式化后的输出文件最后修改时间" + date);
                String name = fod.getName();
                System.out.println( name );
            }
        }else {
            System.out.println( "NUll" );
        }
    }
}
